package com.bwf.map;

import java.util.HashMap;

/**
 * @Version v1.0
 * @Description: TODO
 * @Author ZHANZHONGXIN
 * @Date 2022/5/24 14:02
 * @Copyright 博为峰
 */
public class HashMapDemo01 {
    public static void main(String[] args) {
//        m1();
//        m2();
//        m3();
        HashMap<String, Integer> hashMap = new HashMap<String, Integer>();
        hashMap.put("张三", 20);
        hashMap.put("张三", 30);
        hashMap.put("李四", 40);
        hashMap.put("王五", 50);
        System.out.println(hashMap.get("张三"));

    }

    private static void m3() {
        HashMap<String, Integer> hashMap = new HashMap<String, Integer>();
        hashMap.put("张三", 20);
        hashMap.put("张三", 30);
        hashMap.put("李四", 40);
        hashMap.put("王五", 50);
        System.out.println(hashMap.containsKey("王五"));
        System.out.println(hashMap.containsValue(50));
        System.out.println(hashMap.isEmpty());
        hashMap.clear();
        System.out.println(hashMap);
    }

    private static void m2() {
        HashMap<String, Integer> hashMap = new HashMap<String, Integer>();
        hashMap.put("张三", 20);
        hashMap.put("张三", 30);
        hashMap.put("李四", 40);
        hashMap.put("王五", 50);
        hashMap.remove("王五");
        System.out.println(hashMap);
    }

    private static void m1() {
        HashMap<String, Integer> hashMap = new HashMap<String, Integer>();
        System.out.println(hashMap.put("张三", 20));
        System.out.println(hashMap.put("张三", 30));
    }
}
